﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace ClientApp
{
    public partial class ClientApp : Form
    {
        public bool EmployerFormOpened { get; set; }
        public bool CandidateFormOpened { get; set; }
        public bool AdminFormOpened { get; set; }

        public List<string> CandidateRequests { get; set; }
        public List<string> EmployerRequests { get; set; }

        public ClientApp()
        {
            InitializeComponent();

            EmployerFormOpened = CandidateFormOpened = AdminFormOpened = false;
            CandidateRequests = new List<string>();
            EmployerRequests = new List<string>();
        }
        
        private void LogAsAdminButton_Click(object sender, EventArgs e)
        {
            AdminPasswordTextBox.Visible = true;
            AdminPasswordTextBox.Focus();
        }

        private void AdminPasswordTextBox_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter && AdminPasswordTextBox.Text != "")
            {
                if (!AdminFormOpened)
                {
                    AdminFormOpened = true;
                    Form admin = new AdminForm(this);
                    admin.Show();
                    AdminPasswordTextBox.Clear();
                    AdminPasswordTextBox.Visible = false;
                }
                else
                {
                    MessageBox.Show("Окно работы с администратором уже открыто.", "Ошибка");
                }
            }
        }

        private void RagisterCandidateButton_Click(object sender, EventArgs e)
        {
            Form candidate_reg = new CandidateRegForm();
            candidate_reg.Show();
        }

        private void RegisterEmployerButton1_Click(object sender, EventArgs e)
        {
            Form employer_reg = new EmployerRegForm();
            employer_reg.Show();
        }

        private void LoginAsCandidateButton_Click(object sender, EventArgs e)
        {
            if (!CandidateFormOpened)
            {
                Form candidate = new CandidateForm(this);
                CandidateFormOpened = true;
                candidate.Show();
            }
            else
            {
                MessageBox.Show("Окно работы с соискателем уже открыто.", "Ошибка");
            }
        }

        private void LoginAsEmployerButton_Click(object sender, EventArgs e)
        {
            if (!EmployerFormOpened)
            {
                Form employer = new EmployerForm(this);
                EmployerFormOpened = true;
                employer.Show();
            }
            else
            {
                MessageBox.Show("Окно работы с работодателем уже открыто.", "Ошибка");
            }
        }
    }
}
